package com.shanshan.manage.web.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.shanshan.manage.common.annotation.Log;
import com.shanshan.manage.common.core.controller.BaseController;
import com.shanshan.manage.common.core.domain.AjaxResult;
import com.shanshan.manage.common.enums.BusinessType;
import com.shanshan.manage.web.domain.AGuest;
import com.shanshan.manage.web.service.IAGuestService;
import com.shanshan.manage.common.utils.poi.ExcelUtil;
import com.shanshan.manage.common.core.page.TableDataInfo;

/**
 * 客户Controller
 *
 * @author zhaoShuHeng
 * @date 2023-08-30
 */
@RestController
@RequestMapping("/aGuest/aGuest")
public class AGuestController extends BaseController {
    @Autowired
    private IAGuestService aGuestService;

    /**
     * 查询客户列表
     */
    @PreAuthorize("@ss.hasPermi('aGuest:aGuest:list')")
    @GetMapping("/list")
    public TableDataInfo list(AGuest aGuest) {
        startPage();
        List<AGuest> list = aGuestService.selectAGuestList(aGuest);
        return getDataTable(list);
    }

    /**
     * 导出客户列表
     */
    @PreAuthorize("@ss.hasPermi('aGuest:aGuest:export')")
    @Log(title = "客户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AGuest aGuest) {
        List<AGuest> list = aGuestService.selectAGuestList(aGuest);
        ExcelUtil<AGuest> util = new ExcelUtil<AGuest>(AGuest.class);
        util.exportExcel(response, list, "客户数据");
    }

    /**
     * 获取客户详细信息
     */
    @PreAuthorize("@ss.hasPermi('aGuest:aGuest:query')")
    @GetMapping(value = "/{guestId}")
    public AjaxResult getInfo(@PathVariable("guestId") Long guestId) {
        return success(aGuestService.selectAGuestByGuestId(guestId));
    }

    /**
     * 新增客户
     */
    @PreAuthorize("@ss.hasPermi('aGuest:aGuest:add')")
    @Log(title = "客户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AGuest aGuest) {
        return toAjax(aGuestService.insertAGuest(aGuest));
    }

    /**
     * 修改客户
     */
    @PreAuthorize("@ss.hasPermi('aGuest:aGuest:edit')")
    @Log(title = "客户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AGuest aGuest) {
        return toAjax(aGuestService.updateAGuest(aGuest));
    }

    /**
     * 删除客户
     */
    @PreAuthorize("@ss.hasPermi('aGuest:aGuest:remove')")
    @Log(title = "客户", businessType = BusinessType.DELETE)
    @DeleteMapping("/{guestIds}")
    public AjaxResult remove(@PathVariable Long[] guestIds) {
        return toAjax(aGuestService.deleteAGuestByGuestIds(guestIds));
    }
}
